#include "DynamicSprite.h"

namespace gaim{

    DynamicSprite::DynamicSprite(const std::map<std::string, Image>& images,
                                 const std::string& startingImage,
                                 const Point2& pos, const Vector2& vel,
                                 const int& z, bool isRect) :
                                 Sprite(images, startingImage, pos, z, isRect),
                                        velocity_(vel) {}

    DynamicSprite* DynamicSprite::getInstance(const std::map<std::string, Image>& images,
                                              const std::string& startingImage, const Point2& pos,
                                              const Vector2& vel, const int& z, bool isRect){
        return new DynamicSprite(images, startingImage, pos, Vector2(0,0), z, isRect);
    }

    void DynamicSprite::update(const std::set<Sprite*, SpritePointerComparator>& sprites, const double dt){
        move(velocity_ * dt);
        
    }

    void DynamicSprite::move(const double x, const double y){
        place(getPos() + Vector2(x, y));
    }

    void DynamicSprite::move(const Vector2& vec){
        place(getPos() + vec);
    }

    void DynamicSprite::setVel(const Vector2& vel){
        velocity_ = vel;
    }
    void DynamicSprite::accelerate(const Vector2& acc){
        velocity_ += acc;
    }

    const Vector2& DynamicSprite::getVel() const{
        return velocity_;
    }
    
    void DynamicSprite::onCollision(){
        ;//std::cout << "dynamicsprite collide-test" << std::endl;
    }

}
